Fix accidental use of the format mutex instead of the debug mutex.
authorØyvind Kolås <pippin@gimp.org>
Sat, 21 Nov 2009 18:31:50 +0000 (18:31 +0000)
committerØyvind Kolås <pippin@gimp.org>
Sat, 21 Nov 2009 18:31:50 +0000 (18:31 +0000)
The memory statistics book-keeping was reusing the BablFormat flag mutex
thus deadlocking with pthreads mutexes since they are not recursive by
default.

babl/babl-memory.c

index 304651cb5c19e51cc0d916c687bfc635da6e4076..b228447d0905d254dee2f9558228f2891bba7f1a 100644 (file)
@@ -118,9 +118,9 @@ babl_malloc (size_t size)
   BAI (ret)->signature = signature;
   BAI (ret)->size      = size;
 #if BABL_DEBUG_MEM
-  babl_mutex_lock (babl_format_mutex); 
+  babl_mutex_lock (babl_debug_mutex); 
   mallocs++;
-  babl_mutex_unlock (babl_format_mutex); 
+  babl_mutex_unlock (babl_debug_mutex); 
 #endif
   return (void *) (ret);
 }
@@ -140,11 +140,11 @@ babl_dup (void *ptr)
   memcpy (ret, ptr, BAI (ptr)->size);
 
 #if BABL_DEBUG_MEM
-  babl_mutex_lock (babl_format_mutex); 
+  babl_mutex_lock (babl_debug_mutex); 
   dups++;
   mallocs--;
+  babl_mutex_unlock (babl_debug_mutex); 
 #endif
-  babl_mutex_unlock (babl_format_mutex); 
   return NULL;
 }
 
@@ -193,9 +193,9 @@ babl_free (void *ptr,
                 BAI (format->image_template)->signature = NULL;
                 free_f (BAI (format->image_template));
 #if BABL_DEBUG_MEM
-                babl_mutex_lock (babl_format_mutex); 
+                babl_mutex_lock (babl_debug_mutex); 
                 frees++;
-                babl_mutex_unlock (babl_format_mutex); 
+                babl_mutex_unlock (babl_debug_mutex); 
 #endif
               }
             format->image_template = NULL;
@@ -213,9 +213,9 @@ babl_free (void *ptr,
   BAI (ptr)->signature = NULL;
   free_f (BAI (ptr));
 #if BABL_DEBUG_MEM
-  babl_mutex_lock (babl_format_mutex); 
+  babl_mutex_lock (babl_debug_mutex); 
   frees++;
-  babl_mutex_unlock (babl_format_mutex); 
+  babl_mutex_unlock (babl_debug_mutex); 
 #endif
 }
 
@@ -258,9 +258,9 @@ babl_realloc (void  *ptr,
       memcpy (ret, ptr, babl_sizeof (ptr));
       babl_free (ptr);
 #if BABL_DEBUG_MEM
-      babl_mutex_lock (babl_format_mutex); 
+      babl_mutex_lock (babl_debug_mutex); 
       reallocs++;
-      babl_mutex_unlock (babl_format_mutex); 
+      babl_mutex_unlock (babl_debug_mutex); 
 #endif
       return ret;
     }
@@ -284,10 +284,10 @@ babl_calloc (size_t nmemb,
   memset (ret, 0, nmemb * size);
 
 #if BABL_DEBUG_MEM
-  babl_mutex_lock (babl_format_mutex); 
+  babl_mutex_lock (babl_debug_mutex); 
   callocs++;
   mallocs--;
-  babl_mutex_unlock (babl_format_mutex); 
+  babl_mutex_unlock (babl_debug_mutex); 
 #endif
   return ret;
 }
@@ -315,10 +315,10 @@ babl_strdup (const char *s)
   strcpy (ret, s);
 
 #if BABL_DEBUG_MEM
-  babl_mutex_lock (babl_format_mutex); 
+  babl_mutex_lock (babl_debug_mutex); 
   strdups++;
   mallocs--;
-  babl_mutex_unlock (babl_format_mutex); 
+  babl_mutex_unlock (babl_debug_mutex); 
 #endif
   return ret;
 }